<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="查询系统" left-arrow @click-left="$router.go(-1)"></van-nav-bar>




		<div class="goodsFromWarp">
				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">仓位编码：</div>
						</div>
						<van-field
							 @keyup="onEnter($event,do_inputcwno)"
							 class="skuInput"
							 v-model="editForm.cwno"
							 placeholder="请填写仓位编码"
							 clearable
						 />
				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">商品编码：</div>
						</div>
						<van-field
							 ref="inputField"
							 @keyup="onEnter($event,do_inputitemid)"
							 class="skuInput"
							 v-model="editForm.itemid"
							 placeholder="请填写商品编码"
							 clearable
						 />
				</div>
		</div>


		<div class="skuBtn">
			<van-button type="info" :disabled="isdisabled" @click="_getItemid()">查询任务</van-button>
		</div>


		<div class="table-responsive" v-if="lingquData[0].djtype == 'S' " >
		  <el-table
						border
						header-row-class-name="header-table"
						height="220px"
		        :data="lingquData"
		        style="width: 100%">
					 <el-table-column type="index" 			label="序" 			  width="50" align="center"></el-table-column>
					 <el-table-column prop="shserno_s"	label="标签"		  width="90" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="whsid"			label="仓库"		  width="150" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="itemid"			label="商品编码"	  width="100" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="subsname"		label="品名"		  width="200" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="pack" 			label="箱数"  	  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="unit" 			label="箱装"  	  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="qty" 				label="散数" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="totqty" 		label="总数" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="totqty" 		label="总数" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="p_date" 		label="生产日期"  width="120" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="subid" 			label="子码" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="sptmid" 		label="条码" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="shserno_z" 	label="主标签" 	  width="90" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="shr" 				label="主标签" 	  width="80" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="mb_cwno" 		label="上架位" 	  width="90" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="sjr" 				label="上架人" 	  width="90" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="sj" 				label="上架时间"  width="120" :show-overflow-tooltip="true"></el-table-column>
		 </el-table>
		</div>


		<div class="table-responsive" v-if="lingquData[0].djtype == 'J' " >
		  <el-table
						border
						header-row-class-name="header-table"
						height="220px"
		        :data="lingquData"
		        style="width: 100%">
					 <el-table-column type="index" 			label="序" 			  width="50" align="center"></el-table-column>
					 <el-table-column prop="storename"	label="门店名"	  	width="100" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="subsname"		label="品名"		  width="200" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="pack" 			label="箱数"  	  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="unit" 			label="箱装"  	  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="qty" 				label="散数" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="yjtotqty" 	label="总数" 		  width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="qr_status" 	label="确认状态" 	width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="jhrq" 			label="容器" 			width="100" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="oper_qr" 		label="确认人" 		width="100" :show-overflow-tooltip="true"></el-table-column>
		  </el-table>
		</div>


		<div class="table-responsive" v-if="lingquData[0].djtype == 'P' " >
		  <el-table
						border
						header-row-class-name="header-table"
						height="220px"
		        :data="lingquData"
		        style="width: 100%">
					 <!-- <el-table-column type="index" 			label="序" 			width="45" align="center"></el-table-column> -->
					 <el-table-column prop="cwno"				label="仓位"	  	width="80" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="whsid"			label="仓库"		  width="70" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="subsname"		label="品名"		  width="80" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="pack" 			label="箱数"  	  width="45" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="unit" 			label="箱装"  	  width="45" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="qty" 				label="散数" 		 width="45" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="totqty" 		label="总数" 		 width="45" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="p_date" 		label="生产日期" 	width="120" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="subid" 		  label="子码" 			width="60" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="shserno"	  label="入库标签"		width="90" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="itemid" 	  label="商品编码" 	width="120" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="yfpqty" 	  label="已分配数" 	width="120" :show-overflow-tooltip="true"></el-table-column>
					 <el-table-column prop="shserno_s"	label="入库标签"		width="90" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="shr"	      label="收货人"		  width="90" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="sjr"	      label="上架人"		  width="90" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="mb_cwno"	  label="上架人"		  width="90" :show-overflow-tooltip="true"> </el-table-column>
					 <el-table-column prop="sj"	  			label="上架时间"		width="90" :show-overflow-tooltip="true"> </el-table-column>
		  </el-table>
		</div>


	</div>
</template>

<script>

export default {
  name: 'searchSystem',
  data() {
    return {
			editForm:{
				cwno:'', //J01768582  S02026343 C2240412
				itemid:'',
			},
			isdisabled:false,
			lingquData:[
				{
					djtype:'P',
					itemid:'',
					subsname:'',
					// {{item.
					// itemid:'wqweqweqew',}}-{{item.subsname}}
				}
			],
			isLingQuVisible:false,
		};
  },
	computed: {
		 ryuser: function(){
			 return this.GWO(true).gUSER;
		 },
	},
  methods: {
		do_inputcwno(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.cwno = pmtxt
			this.$refs.inputField.focus();
			// this.saveGoodsBtn()
		},
		do_inputitemid(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.itemid = pmtxt
			this._getSkuDetail()
		},
		_getSkuDetail(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_chaxun',
					'i':this.FNULLE([
					'opmode','qry_item005',
						'czyid',this.ryuser.operatorid,
						'kqid', this.ryuser.kqid,
						'cwno',this.editForm.cwno,
						'itemid',this.editForm.itemid,
					])
				},'查询系统',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到商品编码详情")
					console.log(rtn_json_obj)
					if(!rtn_json_obj || !rtn_json_obj.length) {
						console.log('没有返回数据');
						return;
					}

					if(!rtn_json_obj[0].djtype) {
						console.log('数据格式不正确');
						return;
					}

					if(rtn_json_obj[0].djtype > '') {
						_self.lingquData = rtn_json_obj
					}
				}
			});
		},
    _getItemid(){
      var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_chaxun',
					'i':this.FNULLE([
					'opmode','qry_item005',
						'czyid',this.ryuser.operatorid,
						'kqid', this.ryuser.kqid,
						'itemid',this.editForm.itemid,
					])
				},'转换商品编码',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("转换商品编码")
					console.log(rtn_json_obj)
          if(rtn_json_obj.length > 0){ //转换商品编码成功
            _self.editForm.itemid = rtn_json_obj[0].itemid //转换后的商品编码
          }
          _self.lingquBtn()  //查询任务
				}
			});
    },
		lingquBtn(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_chaxun',
					'i':this.FNULLE([
					'opmode','Y_CXXT_qrybill',
						'czyid',this.ryuser.operatorid,
						'kqid', this.ryuser.kqid,
						'cwno',this.editForm.cwno,
						'itemid',this.editForm.itemid,
					])
				},'查询系统',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到查询系统")
					console.log(rtn_json_obj)
					if(!rtn_json_obj || !rtn_json_obj.length) {
						_self.$toast.fail('没有返回数据');
						return;
					}

					if(!rtn_json_obj[0].djtype) {
						_self.$toast.fail('数据格式不正确');
						return;
					}

					if(rtn_json_obj[0].djtype > '') {
						_self.lingquData = rtn_json_obj
					}
				}
			});
		},
  },
  mounted() {

  },
	components: {

	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}



	div.carCardWarp{
		width: 94%;
		margin-left: 3%;
		margin-right: 3%;
		margin-top: 20px;
		font-size: 20px;
		font-weight: bold;
		div.carCard{
			position: relative;
			border-left: 5px solid #4998FF;
			box-sizing: border-box;
			padding-left: 10px;
			padding-right: 10px;
			border-radius:5px;
			background-color: #fff;
			padding-top: 10px;
			padding-bottom: 10px;
			margin-bottom:15px;
			div.status{
				position: absolute;
				right: 0;
				top: 0;
				width: 65px;
				height: 30px;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				font-size: 12px;
				border-radius: 0px 10px 0px 10px;
			}
			div.goodRow{
				margin-bottom:8px;
				span{
					display: inline-block;
					width:100px;
				}
			}
			div.goodsTitleRow{
				display: flex;
				width: 100%;
				div.goodsTitleLabel{
					width: 100px;
				}
				div.skuNoTitle{
					width: calc(100% - 100px);
				}
			}
		}
	}


	div.table-responsive{
			width: 100%;
			overflow-x:scroll;
	}


	.header-table th{
		background-color: #1989fa !important;
		padding: 0 !important;
	}

	/deep/.el-table th.el-table__cell{
		background-color: #1989fa !important;
		color: #fff !important;
		padding: 8px !important;
		color: #666;
	}


	/deep/.el-table .el-table__cell{
		padding: 8px !important;
	}

</style>
